package com.me;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * @author shichenguang
 * @desciption 描述
 * @date 2020-04-22 16:23
 */
public class Question {
    public static void main(String[] args) {


        /**
         //1.计算字符个数
        Scanner in = new Scanner(System.in);
        String str1 = in.nextLine();
        String str = in.nextLine();
        getCharNum(str1, str);
         */

        /**2.计算字符串最后一个单词的长度
         *  Scanner in = new Scanner(System.in);
             String s = in.nextLine();

             getLastWordLength(s);
         */

          //3.暂时放着
//        Scanner sc = new Scanner(System.in);
//        //while循环用于处理多组数据
//        while (sc.hasNext()) {
//            int num = sc.nextInt();//输入的数的个数
//            TreeSet<Integer> set = new TreeSet<Integer>();
//            for (int i = 0; i < num; i++) {
//                int curr = sc.nextInt();
//                set.add(curr);
//            }
//            for (Integer i : set) {
//                System.out.println(i);
//            }
//        }



        /**4.字符串分隔
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String str = scanner.nextLine();
            StringBuilder sb = new StringBuilder(str);
            if(sb.length()%8 != 0){
                int zeroNum = 8-str.length() % 8;
                for (int i = 0;i< zeroNum;i++){
                    sb.append("0");
                }
            }
            while (sb.length()>0){
                String substring = sb.substring(0, 8);
                System.out.println(substring);
                sb.delete(0,8);
            }
        }
         */


        /**4.输入一个正整数，按照从小到大的顺序输出它的所有质数的因子（如180的质数因子为2 2 3 3 5 ）
        Scanner scanner = new Scanner(System.in);
        long l = scanner.nextLong();
        getResultNum(180);

         */

        /**写出一个程序，接受一个正浮点数值，输出该数值的近似整数值。如果小数点后数值大于等于5,向上取整；小于5，则向下取整
        Scanner scanner = new Scanner(System.in);
        double v = scanner.nextDouble();
        int resultNum = (int)(v+0.5);
         */



        /**8. 合并表记录
        Scanner scanner = new Scanner(System.in);
        TreeMap<Integer, Integer> dataMap = new TreeMap<>();
        while (scanner.hasNext()){
            int lines = scanner.nextInt();
            for (int i = 0; i<lines; i++){
                String s = scanner.nextLine();
                Integer index = scanner.nextInt();   //这里需要注意哈
                Integer value = scanner.nextInt();   //这里需要注意哈
                if(dataMap.get(index) != null){
                    dataMap.put(index,dataMap.get(index)+value);
                }else {
                    dataMap.put(index,value);
                }
            }

            dataMap.forEach((key,value) ->{
                System.out.println(key+" "+String.valueOf(value));
            });
        }
         */

        /** 9. 提取不重复的整数
         * @description
         * @author shichenguang
         * @date 2020/4/26 14:42

        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        StringBuilder sb = new StringBuilder(s);
        StringBuilder reSb = sb.reverse();
        HashSet<Object> set = new HashSet<>();
        StringBuilder resultNum = new StringBuilder();
        for (int i = 0; i < reSb.length(); i++) {
            if(set.add(reSb.substring(i,i+1))){
                resultNum.append(reSb.subSequence(i,i+1));
            }
        }
        System.out.println(resultNum);
         */

//        Scanner scanner = new Scanner(System.in);


    }



    /**
     * @description 2.计算字符串最后一个单词的长度
     * @author shichenguang
     * @date 2020/4/22 16:48
     */
    private static void getLastWordLength(String s) {
        if(s.length()>49999){
            System.out.println("输入字符长度不能超过50000");
        }
        String[] split = s.split(" ");
        String lastWord = split[split.length - 1];
        System.out.println(lastWord.length());
    }

    /**
     * @description 1.计算字符个数
     * @author shichenguang
     * @date 2020/4/22 16:40
     */
    private static void getCharNum(String str1, String str) {
        int num = 0;
        for (int i = 0; i < str1.length(); i++) {
            if(str.equalsIgnoreCase(String.valueOf(str1.charAt(i)))){
                num = num+1;
            }
        }
        System.out.println(num);
    }


    /**
     * @description 输入一个正整数，按照从小到大的顺序输出它的所有质数的因子（如180的质数因子为2 2 3 3 5 ）
     * @author shichenguang
     * @date 2020/4/26 14:02
     */
    private static String getResultNum(Long l){
        int num = 2;
        String result = "";
        while (l!=1){
            //从2开始
            if(l % num == 0){
                l = l/num;
                result += num + " ";//输出这个质数
            }else{
                num++;
            }
        }
        return result;
    }
}
